﻿namespace FlexField.Metadata.EntityFrameworkCore
{
    /// <summary>
    /// Represents an entity in the metadata system.
    /// </summary>
    /// <typeparam name="TKey">The type used for the primary key for the entity.</typeparam>
    public class DataEntity<TKey> where TKey : IEquatable<TKey>
    {
        /// <summary>
        /// Gets or sets the primary key for this data entity.
        /// </summary>
        public virtual TKey Id { get; set; }

        /// <summary>
        /// Gets or sets the name of this data entity.
        /// </summary>
        public virtual string EntityName { get; set; }

        /// <summary>
        /// Gets or sets the normalized name for this entity.
        /// </summary>
        public virtual string NormalizedEntityName { get; set; }

        /// <summary>
        /// Gets or sets the display name of this data entity.
        /// </summary>
        public virtual string DisplayName { get; set; }

        /// <summary>
        /// A random value that must change whenever an entity is persisted to the store
        /// </summary>
        public virtual string ConcurrencyStamp { get; set; }

        /// <summary>
        /// Gets or sets the related entity properties.
        /// </summary>
        public virtual ICollection<DataEntityProperty<TKey>> Properties { get; set; }

        /// <summary>
        /// Gets or sets the related fields.
        /// </summary>
        public virtual ICollection<DataField<TKey>> Fields { get; set; }

        public override string ToString()
        {
            return EntityName;
        }
    }
}
